#include"cuda.cuh"

int main()
{
	if(!InitCUDA()) 
	{
        return -1;
    }
	printf("CUDA initialized.\n");

	float4 *gpuarray1,*gpuarray2;
	float *result;
	int num=10;

	cudaMalloc((void**) &gpuarray1, sizeof(float4) *num);
	cudaMalloc((void**) &gpuarray2, sizeof(float4) *num);
	cudaMalloc((void**) &result, sizeof(float) *num);

	float4 array1[100];
	float4 array2[100];
	for(int i=0;i<num;++i)
	{
		array1[i].w=i+1;
		array1[1].x=0;
		array1[1].y=1;
		array1[1].z=2;

		array2[i].w=2;
		array2[1].x=10;
		array2[1].y=11;
		array2[1].z=12;
	}
	cudaMemcpy(gpuarray1, array1, sizeof(float4) * num, cudaMemcpyHostToDevice);
	cudaMemcpy(gpuarray2, array2, sizeof(float4) * num, cudaMemcpyHostToDevice);

	sumOfDataTerm<<<1,num>>>(gpuarray1,gpuarray2,result);
	printf("CUDA Computed.\n");
	float buffer[100];
	cudaMemcpy(buffer,result, sizeof(float) * num, cudaMemcpyHostToDevice);
	cudaFree(gpuarray1);
	cudaFree(gpuarray2);
	cudaFree(result);

	return 0;
}